package com.bangyu.monitor.modular.system.biz;

import com.bangyu.monitor.core.common.constant.ConstantEnum;
import com.bangyu.monitor.core.shiro.ShiroKit;
import com.bangyu.monitor.modular.system.entity.Bridge;
import com.bangyu.monitor.modular.system.service.BridgeService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Auther: zhangxue
 * @Date: 19/5/3 10:23
 * @Description:
 */
@Component
public class BridgeBiz {

    @Autowired
    private BridgeService bridgeService;

    public List<Bridge> listByPermission(String condition){
        List<Bridge> bridges = null;
        if(ShiroKit.isAdmin()){
            bridges = this.bridgeService.listAll(condition);
        }else if(ShiroKit.hasRole(ConstantEnum.Role.MANAGER.getRoleName())){
            bridges = this.bridgeService.listByManagerPerson(ShiroKit.getUser().getId(),condition);
        }else{
            bridges = this.bridgeService.listByShowToTourist(condition);
        }
        return bridges;
    }

    public Page<Bridge> pageByPermission(String condition){
        Page<Bridge> page = null;
        if(ShiroKit.isAdmin()){
            page = this.bridgeService.pageAll(condition);
        }else if(ShiroKit.hasRole(ConstantEnum.Role.MANAGER.getRoleName())){
            page = this.bridgeService.pageByManagerPerson(ShiroKit.getUser().getId(),condition);
        }else{
            page = this.bridgeService.pageByShowToTourist(condition);
        }
        return page;
    }
}
